package data;

import java.io.Serializable;
import java.util.HashMap;

/**
 * An generic object used by the editor for holding abstract data.
 * 
 * @author Richard
 */
public class DataObject extends HashMap<String, Object> implements Serializable {

	private static final long serialVersionUID = 3787980247350409427L;

	/*
	 * The guid of this data object. Used for referencing.
	 */
	private String guid;

	/*
	 * The name as displayed in the GUI
	 */
	private String displayName;

	/*
	 * The name of the class using this data object. Used for referencing.
	 */
	private String fqClassName;

	/*
	 * The name of the project that owns this object.
	 */
	protected String owner;

	/*
	 * True if this object can be used by projects other than the owner.
	 */
	protected boolean shared;

	/**
	 * Initializes the attributes and references list.
	 */
	public DataObject(String fqClassName, String guid, String owner) {
		try {
			this.displayName = "New "
					+ Class.forName(fqClassName).getSimpleName();
		} catch (ClassNotFoundException e) {
			this.displayName = "New " + fqClassName;
		}
		this.fqClassName = fqClassName;
		this.guid = guid;
		this.owner = owner;
		this.shared = false;
	}

	/**
	 * Accessor for the name of this data object.
	 * 
	 * @return String The name of this object.
	 */
	public String getGUID() {
		return guid;
	}

	/**
	 * Accessor for the class using this data object.
	 * 
	 * @return String The fully-qualified class name of this object.
	 */
	public String getFQClassName() {
		return fqClassName;
	}

	public String getOwner() {
		return owner;
	}

	public boolean isShared() {
		return shared;
	}

	public void setShared(boolean shared) {
		this.shared = shared;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

}
